<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="资源化企业" prop="disposalLandName">
        <el-input v-model="queryParams.disposalLandName" placeholder="请输入资源化企业名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="月份">
        <el-date-picker v-model="daterangeCreatedDate" style="width: 240px" value-format="yyyy-MM" type="monthrange"
          range-separator="-" start-placeholder="开始月份" end-placeholder="结束月份"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['report:resourceLandInfo:list']">导出
        </el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="recordList">
      <el-table-column label="资源化企业" align="center" prop="disposalLandName" show-overflow-tooltip />
      <el-table-column label="产品类别" align="center" prop="sysRubbishTypeName" show-overflow-tooltip />
      <el-table-column label="产品种类" align="center" prop="sysRubbishTypeSubName" show-overflow-tooltip />
      <el-table-column label="填报月份" align="center" prop="month" show-overflow-tooltip />
      <el-table-column label="本月重量(吨)" align="center" prop="weight" show-overflow-tooltip />
      <el-table-column label="累计重量(吨)" align="center" prop="totalWeight" show-overflow-tooltip />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.current" :limit.sync="queryParams.size"
      @pagination="getList" />
  </div>
</template>

<script>
import { listResourceLandInfo } from "@/api/report/report";

export default {
  name: "Report",
  dicts: [],
  data () {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      recordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 修改时间时间范围
      daterangeCreatedDate: [],
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
        projectName: null,
        projectKindId: null,
        createdDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created () {
    this.getList();
  },
  methods: {
    /** 查询垃圾申报量统计列表 */
    getList () {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeCreatedDate && '' != this.daterangeCreatedDate) {
        this.queryParams.params["beginCreatedDate"] = this.daterangeCreatedDate[0];
        this.queryParams.params["endCreatedDate"] = this.daterangeCreatedDate[1];
      }
      listResourceLandInfo(this.queryParams).then(response => {
        this.recordList = response.records;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.daterangeCreatedDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport () {
      this.download('report/resourceLandInfo/exportXls', {
        ...this.queryParams
      }, `资源化企业再生产品月度信息汇总表_${new Date().getTime()}.xlsx`)
    },
  }
};
</script>
